import { request } from "@umijs/max";;
import { UMS_REQUEST_PREFIX } from "@/utils/config";
import { activityTypes, adPageTypes, couponTypes } from "@/constants/types";

// 活动
/**
 * 活动列表
 * @returns 
 */
export async function fetchActivityList(params: {
  pageNum: number;
  pageSize: number;
  status: string | undefined
}) {
  return request(`${UMS_REQUEST_PREFIX}/crm/activity/list`, {
    method: 'POST',
    data: params,
    dataField: 'data'
  });
}
/**
 * 活动下拉列表
 * @returns 
 */
export async function fetchActivityOptions() {
  return request(`${UMS_REQUEST_PREFIX}/crm/activity/options`, {
    method: 'POST',
    dataField: 'data'
  });
}
/**
 * 添加活动
 * @returns 
 */
export async function addActivity(params: activityTypes) {
  return request(`${UMS_REQUEST_PREFIX}/crm/activity/add`, {
    method: 'POST',
    data: params
  });
}
/**
 * 修改活动
 * @returns 
 */
export async function updateActivity(params: activityTypes) {
  return request(`${UMS_REQUEST_PREFIX}/crm/activity/update`, {
    method: 'POST',
    data: params
  });
}
/**
 * 活动详情
 * @returns 
 */
export async function fetchActivityDetail(params: {id: string}) {
  return request(`${UMS_REQUEST_PREFIX}/crm/activity/detail`, {
    method: 'POST',
    data: params,
    dataField: 'data'
  });
}
/**
 * 添加个人活动码
 * @returns 
 */
export async function activityAddMember(params: {
  activityId: string;
  mobile: string;
}) {
  return request(`${UMS_REQUEST_PREFIX}/crm/activity/addMember`, {
    method: 'POST',
    data: params
  });
}
/**
 * 查看活动码
 * @returns 
 */
export async function activityMembers(params: {id: string}) {
  return request(`${UMS_REQUEST_PREFIX}/crm/activity/activityMembers`, {
    method: 'POST',
    data: params,
    dataField: 'data'
  });
}
/**
 * 开启活动
 * @returns 
 */
export async function activityStartActivity(params: {id: string}) {
  return request(`${UMS_REQUEST_PREFIX}/crm/activity/startActivity`, {
    method: 'POST',
    data: params
  });
}
/**
 * 优惠券列表
 * @returns 
 */
export async function fetchCouponList(params: {
  pageNum: number;
  pageSize: number;
}) {
  return request(`${UMS_REQUEST_PREFIX}/crm/coupon/list`, {
    method: 'POST',
    data: params,
    dataField: 'data'
  });
}
/**
 * 新建优惠券
 * @returns 
 */
export async function addCoupon(params: couponTypes) {
  return request(`${UMS_REQUEST_PREFIX}/crm/coupon/add`, {
    method: 'POST',
    data: params
  });
}
/**
 * 优惠券下拉列表
 * @returns 
 */
export async function fetchCouponOptions() {
  return request(`${UMS_REQUEST_PREFIX}/crm/coupon/options`, {
    method: 'POST',
    dataField: 'data'
  });
}
/**
 * 广告页列表
 * @returns 
 */
export async function fetchAdPageList(params: {pageNum: number, pageSize: number}) {
  return request(`${UMS_REQUEST_PREFIX}/base/adPage/list`, {
    method: 'POST',
    dataField: 'data',
    data: params
  });
}
/**
 * 新建广告页
 * @returns 
 */
export async function adPageAdd(params: adPageTypes) {
  return request(`${UMS_REQUEST_PREFIX}/base/adPage/add`, {
    method: 'POST',
    data: params
  });
}
/**
 * 修改广告页
 * @returns 
 */
export async function adPageUpdate(params: adPageTypes) {
  return request(`${UMS_REQUEST_PREFIX}/base/adPage/update`, {
    method: 'POST',
    data: params
  });
}
/**
 * 广告页详情
 * @returns 
 */
export async function fetchAdPageDetail(params: {id: string}) {
  return request(`${UMS_REQUEST_PREFIX}/base/adPage/detail`, {
    method: 'POST',
    data: params,
    dataField: 'data',
  });
}
/**
 * 广告页下拉列表
 * @returns 
 */
export async function fetchAdPageOptions() {
  return request(`${UMS_REQUEST_PREFIX}/base/adPage/options`, {
    method: 'POST',
    dataField: 'data',
  });
}
/**
 * 广告位下拉列表
 * @returns 
 */
export async function fetchAdPageSlotOptions(params: {pageId: string}) {
  return request(`${UMS_REQUEST_PREFIX}/base/adPage/slotOptions`, {
    method: 'POST',
    data: params,
    dataField: 'data',
  });
}
/**
 * 广告列表
 * @returns 
 */
export async function fetchAdList(params: any) {
  return request(`${UMS_REQUEST_PREFIX}/base/ad/list`, {
    method: 'POST',
    dataField: 'data',
    data: params
  });
}
/**
 * 新建广告
 * @returns 
 */
export async function adAdd(params: any) {
  return request(`${UMS_REQUEST_PREFIX}/base/ad/add`, {
    method: 'POST',
    data: params
  });
}
/**
 * 修改广告
 * @returns 
 */
export async function adUpdate(params: any) {
  return request(`${UMS_REQUEST_PREFIX}/base/ad/update`, {
    method: 'POST',
    data: params
  });
}
/**
 * 广告详情
 * @returns 
 */
export async function fetchAdDetail(params: any) {
  return request(`${UMS_REQUEST_PREFIX}/base/ad/detail`, {
    method: 'POST',
    data: params,
    dataField: 'data',
  });
}
/**
 * 下架
 * @returns 
 */
export async function fetchAdTabNum(params: any) {
  return request(`${UMS_REQUEST_PREFIX}/base/ad/tabNum`, {
    method: 'POST',
    data: params,
    dataField: 'data'
  });
}
/**
 * 上架
 * @returns 
 */
export async function adOnSale(params: any) {
  return request(`${UMS_REQUEST_PREFIX}/base/ad/onSale`, {
    method: 'POST',
    data: params,
  });
}
/**
 * 下架
 * @returns 
 */
export async function adOffSale(params: any) {
  return request(`${UMS_REQUEST_PREFIX}/base/ad/offSale`, {
    method: 'POST',
    data: params,
  });
}
/**
 * 绑定广告位
 * @returns 
 */
export async function adBindAdSlot(params: any) {
  return request(`${UMS_REQUEST_PREFIX}/base/ad/bindAdSlot`, {
    method: 'POST',
    data: params,
  });
}
/**
 * 显示广告位
 * @returns 
 */
export async function fetchAdAdSlot(params: any) {
  return request(`${UMS_REQUEST_PREFIX}/base/ad/adSlot`, {
    method: 'POST',
    data: params,
  });
}
/**
 * 显示广告位
 * @returns 
 */
export async function adRefreshAdData(params: any) {
  return request(`${UMS_REQUEST_PREFIX}/base/ad/refreshAdData`, {
    method: 'POST',
    data: params,
  });
}